<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script>
        // 使用关键字 extends
        class Animal{
            constructor(name,age) {
                this.name = name;
                this.age = age;
            }
            sayName(){
                return this.name;
            }

            sayAge(){
                return this.age;
            }
        }

        class Dog extends Animal{
            constructor(name,age,color) {
                super(name,age);
                this.color = color;
            }
            // 子类自己的方法
            sayColor(){
                return `${this.name}已经${this.age}岁了，它颜色是${this.color}的`;
            }
            // 重写父类的方法
            sayName() {
                return this.name + super.sayAge() + this.color;
            }
        }
        let dog = new Dog('小黄',28,'red');
        console.log(dog);
        console.log(dog.sayName());
        console.log(dog.sayColor());

        // 如何将多个类混入到一个类中：使用Object.assign()或使用继承与多重继承
    </script>
</body>
</html>